'use strict';
module.exports = (app) => {
  // 商品sku表
  const { STRING, INTEGER, FLOAT } = app.Sequelize;
  const AttributesKey = app.model.define('s_attributesKey', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    project_id: {
      type: INTEGER,
      comment: '项目名',
    },
    keyName: {
      type: STRING,
      comment: '属性名',
      allowNull: false,
    },
    valueName: {
      type: STRING,
      comment: '属性值',
      allowNull: false,
    },
  });
  AttributesKey.associate = function () {
    // 一对多链接商品图片表
    app.model.Tables.Shop.AttributesKey.hasMany(
      app.model.Tables.Shop.AttributesValue,
      {
        foreignKey: 'attribute_id',
      }
    );
  };

  return AttributesKey;
};
